import { createApp } from 'vue'
import App from './App.vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import './assets/iconfont.css'
import './assets/style.css'
import 'element-plus/theme-chalk/dark/css-vars.css'
import { createPinia } from 'pinia'
import piniaPluginPersist from 'pinia-plugin-persist'
import vue3PreviewImage from 'vue3-preview-image'
import router from './router'
import locale from 'element-plus/lib/locale/lang/zh-cn'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import print from 'vue3-print-nb'
import DataVVue3 from '@kjgl77/datav-vue3'
import ECharts from 'vue-echarts'

const app = createApp(App);
import "echarts";
// 挂载ECharts   
app.component('ECharts', ECharts)
document.addEventListener('keydown', function (event) {
  if ((event.ctrlKey === true || event.metaKey === true)
    && (event.which === 61 || event.which === 107
      || event.which === 173 || event.which === 109
      || event.which === 187 || event.which === 189)) {
    event.preventDefault();
  }
}, false);
// 覆盖鼠标滑动
document.body.addEventListener('wheel', (e) => {
  if (e.ctrlKey) {
    if (e.deltaY < 0) {
      e.preventDefault();
      return false;
    }
    if (e.deltaY > 0) {
      e.preventDefault();
      return false;
    }
  }
}, { passive: false });
const pinia = createPinia()
pinia.use(piniaPluginPersist)
// 引入所有图标
import * as Icons from '@element-plus/icons'
// 循环注册所有图标
for (const name in Icons) {
  //name 为icon名称，也是组件名称。使用时：<Edit />，
  //也可以按需增加前缀或者后缀
  // eg: app.component(`eurake-name-${name}`,(Icons as any)[name])
  // 使用时：<eurake-name-Edit />
  // 当然你也可以写一个方法把首字母大写的图标名称改成小写等你想要的任意格式
  app.component(name, (Icons as any)[name])
}
app.use(DataVVue3)
app.use(ElementPlus, { locale: zhCn })
app.use(pinia)
app.use(DataVVue3)
app.use(print)
app.use(router)
app.use(vue3PreviewImage)
app.mount('#app')